package com.tsvetanv.simpleformcontroller.example01.person.system;

import java.beans.PropertyEditorSupport;

import com.tsvetanv.simpleformcontroller.example01.person.mvc.model.ProgrammingLanguage;

public class ProgrammingLanguageEditor extends PropertyEditorSupport {

	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		setValue(ProgrammingLanguage.valueOf(text));
	}

	@Override
	public String getAsText() {
		if (getValue() == null) {
			return "";
		}
		return ((ProgrammingLanguage) getValue()).getName();
	}
}
